/*==============================================================================
 * AUTH: Domenico Romano 5574331
 *       Matthew Baum, 9753095
 * 
 * DATE: January-29-2012
 * EDIT: January-30-2012
 * DESC: Java class to hold assignee at an array of Tasks.
 *==============================================================================*/

package Phase_1;

import java.util.Arrays;

public class Person {


    // Assignee Name
    private String assgn;

    // List of tasks assigned
    private Task[] tasks;

    // Sum of hours assigned
    private int hours = 0;

    // Constructor
    public Person(String assgn, Task[] tasks)
    {
        // Set asignee name & array of tasks
        this.assgn = assgn;
        this.tasks = tasks;

        // Calculate total hours assigned
        calculateHours();
    }

    // Calculate the sum of hours assigned to this Person
    private void calculateHours()
    {
        for(int i = 0; i != tasks.length; ++i)
        {
            hours += tasks[i].getDuration();
        }
    }
            

    // Return assignee name
    public String getAssgn() {
        return assgn;
    }


    // Return array of assigned Tasks
    public Task[] getTasks() {
        return tasks;
    }

    // Return total hours assigned
    public int getHours()
    {
        return hours;
    }

    // Print to String
    @Override
    public String toString() {
        return "IndvTasks [assgn=" + assgn + ", tasks="
                        + Arrays.toString(tasks) + ", getClass()=" + getClass()
                        + ", hashCode()=" + hashCode() + ", toString()="
                        + super.toString() + "]";
    }
}